﻿using IOP.SgrA;
using IOP.SgrA.SilkNet.Vulkan;
using Microsoft.Extensions.Options;
using Silk.NET.Vulkan;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace VkSample81
{
    public class SightingMiddleware : IProductionLineMiddleware<SecondaryVulkanRenderGroup>
    {

        public SightingMiddleware()
        {
        }

        public void Invoke(SecondaryVulkanRenderGroup group, RenderingProductionLineDelegate<SecondaryVulkanRenderGroup> next)
        {
            var camera = group.Camera;
            var view = camera.ViewMatrix;
            var project = camera.ProjectionMatrix;
            var cmd = group.SecondaryCommandBuffer;

            cmd.BindPipeline(PipelineBindPoint.Graphics, group.Pipeline);
            foreach (var item in group.GetContexts())
            {
                item.SetViewMatrix(in view);
                item.SetProjectionMatrix(in project);
                group.ItemProductionLine(item);
            }
        }
    }
}
